

#ifndef __EV_CMD_TYPE_H__
#define __EV_CMD_TYPE_H__

#include <stdint.h>


#pragma pack(push, 1)


/* ------------------------------------- Call -------------------------------------  */
/* down stream, for sdk (0x1000 ~ 0x1FFF)*/

#define EV_CALL_GET_VERSION 0x1002
typedef struct {
    uint8_t type;  // 0x01 -- bootloader, 0x00 -- application
} ev_call_get_version_req_t;
typedef struct {
    uint8_t ret;    // 0x00 -- success, other -- fail
    uint8_t major;
    uint8_t minor;
    uint8_t patch;
    uint32_t build_time;
    uint32_t firm_len;
} ev_call_get_version_rsp_t;

// only for bootloader
#define EV_CALL_ENTER_BOOTLOADER 0x1004
typedef struct {
    uint8_t type;  // 0x35 -- console uart, 0xca -- trans uart
} ev_call_enter_bootloader_req_t;
typedef struct {
    uint8_t ret;    // 0x00 -- success, other -- fail
} ev_call_enter_bootloader_rsp_t;

#define EV_CALL_READ_CONFIG 0x1006
typedef struct {
    uint32_t offset;
    uint32_t len;
} ev_call_read_config_req_t;
typedef struct {
    uint8_t ret;    // 0x00 -- success, other -- fail
    uint8_t data[];
} ev_call_read_config_rsp_t;

#define EV_CALL_WRITE_CONFIG 0x1008
typedef struct {
    uint32_t offset;
    uint8_t data[];
} ev_call_write_config_req_t;
typedef struct {
    uint8_t ret;    // 0x00 -- success, other -- fail
} ev_call_write_config_rsp_t;

#define EV_CALL_READ_UUID 0x100A
typedef struct {
    uint8_t type;
} ev_call_read_uuid_req_t;
typedef struct {
    uint8_t ret;    // 0x00 -- success, other -- fail
    uint8_t uuid[];
} ev_call_read_uuid_rsp_t;

#define EV_CALL_OTA_DATA_LEN 64
#define EV_CALL_OTA_READ 0x100C
typedef struct {
    uint32_t idx;
} ev_call_ota_read_req_t;
typedef struct {
    uint8_t ret;    // 0x00 -- success, other -- fail, 0xff -- param error
    uint8_t data[EV_CALL_OTA_DATA_LEN];
} ev_call_ota_read_rsp_t;

#define EV_CALL_OTA_START 0x100E
typedef struct {
    uint32_t firm_len;
} ev_call_ota_start_req_t;
typedef struct {
    uint8_t ret;    // 0x00 -- success, other -- fail
} ev_call_ota_start_rsp_t;

#define EV_CALL_OTA_DATA 0x1010
typedef struct {
    uint32_t idx;
    uint8_t data[EV_CALL_OTA_DATA_LEN];
} ev_call_ota_data_req_t;
typedef struct {
    uint8_t ret;    // 0x00 -- success, other -- fail
} ev_call_ota_data_rsp_t;

#define EV_CALL_OTA_END 0x1012
// typedef struct {
// } ev_call_ota_end_req_t;
typedef struct {
    uint8_t ret;
} ev_call_ota_end_rsp_t;

#define EV_CALL_RESET 0x1014
typedef struct {
    uint32_t delay_ms; // delay ms before reset
} ev_call_reset_req_t;
typedef struct {
    uint8_t ret;    // 0x00 -- success, other -- fail
} ev_call_reset_rsp_t;



/* ------------------------------------- Call -------------------------------------  */
/* down stream, only for manufacturer (0x4000~0x4FFF)*/

#define EV_CALL_SET_ENCRYPTION 0x478A
typedef struct {
    uint8_t key[32];
} ev_call_set_encryption_req_t;
typedef struct {
    uint8_t ret;    // 0x00 -- success, other -- fail
} ev_call_set_encryption_rsp_t;



/* -------------------------------------- Notification --------------------------------- */
/* upstream, for sdk (0xFF00 ~ 0xFFFF)*/

#define EV_NOTIFY_DEVICE_LOG   0xFF00
// typedef struct {
//     char data[];
// } ev_notify_log_req_t;
// typedef struct {
//     char data[];
// } ev_notify_log_rsp_t;


#pragma pack(pop)

#endif /* __EV_CALL_TYPE_H__ */
